<?php

namespace app\api\validate\user;

use app\api\validate\Validates;

class UserCoupons extends Validates
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
	    'type|购物类型' => 'require|number|>=:0',
        'price|价格' => 'require|float'
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [];

    /**
     * 定义授权场景验证
     * @return $this
     */
    public function sceneAvailable()
    {
        $type = array_keys(config('field.coupons.type'));
        return $this->only(['type','price'])
            ->append('type', 'in:'.implode(',', $type));
    }

}
